package com.zhongkun.datahome.framework.config;

import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import com.zhongkun.datahome.common.utils.SecurityUtils;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.NullValue;

import java.util.List;

/**
 * @author huangjie
 * @since 2025/4/18
 */
public class TenantHandler implements TenantLineHandler {

    private static final List<String> ignoreTableList = List.of("sys_config", "sys_dict_data", "sys_dict_type", "tenant", "sys_job", "sys_user", "sys_menu", "sys_role_menu", "tenant_user");

    @Override
    public Expression getTenantId() {
        // 正常返回当前租户ID
        return new LongValue(SecurityUtils.getTenantId());
    }

    @Override
    public boolean ignoreTable(String tableName) {
        return ignoreTableList.contains(tableName);
    }
}
